﻿@using NewRen.Models;
@using NewRen.Models.ViewModel;
@model NewRen.Models.ViewModel.vEdit

@{
    User user = ViewBag.User as User;
    UserGroup group = ViewBag.UserGroup;
    ViewBag.Title = "牛人管理-牛人修改";
    Layout = "~/Views/Shared/_Layout_UserGroup.cshtml";

}
<div class="ucenter-left account-left-border">
    <div class="ucneter-l-head cf">
        <div class="ulhead-headicon">
            @if (group.Picture == null)
            {
                <img src="/Images/userphoto.png" width="50" height="50"
                     alt=@group.GroupName style="border-radius:50%;" />
            }
            else
            {
                <img src="/UserGroup/ShowPicture/@group.ID" width="50"
                     alt=@group.GroupName height="50" style="border-radius:50%;" />
            }

        </div>
        <div class="ulhead-info">
            <p class="ulhead-info-uname">@group.GroupName</p>

            <div class="ulhead-info-tool">
                <a class="ulhead-icon icon-lock ucenter-mail " href="/UserGroup/PwdEdit/@group.ID" title="修改密码">
                    <div class="ucenter-mail-tip">修改密码</div>
                </a>
                <a href="/User/Edit/@group.ID"
                   class="ulhead-icon icon-setting ucenter-mail" title="修改牛棚信息"></a>
            </div>
        </div>
    </div>
    <div class="ucenter-l-list">
        <ul class="ullist-ul">
            <li id="uclick">
                <a href="/UserGroup/Show/@group.ID">牛棚中心</a>
            </li>
            <li id="uclick1">
                <a href="/UserGroup/Edit/@group.ID">牛棚设置</a>
            </li>
            <li id="uclick2" class="active">
                <a href="/UserGroup/UserManager/@group.ID">牛棚牛人</a>
            </li>
        </ul>
    </div>
</div>
<div class="ucenter-right cf">
    <div class="ucenter-right-head">
        <span class="ucenter-right-head-selected"><a href="/UserGroup/UserEdit/@user.ID">信息修改</a></span>
        <span class="ucenter-right-head-show"><a href="/UserGroup/UserPwdEdit/@user.ID">密码修改</a></span>
        <span class="ucenter-right-head-show"><a href="/UserGroup/UserPictureEdit/@user.ID">更换头像</a></span>
    </div>
    <div style="display:block;margin-left:40px">
        @using (Html.BeginForm("UserEdit", "UserGroup", FormMethod.Post, new { onsubmit = "return GroupEditCheck();" }))
        {
            @Html.AntiForgeryToken()
            @Html.HiddenFor(model => model.GroupName)
            <div class=" form-item">
                <div class="item-label">
                    <label>用户名：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.UserName, new { @Value = user.UserName, @class = "txt sm" })
                </div>
            </div>
            <div class=" form-item">
                <div class="item-label">
                    <label>真实姓名：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.RealName, new { @Value = user.RealName, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>性别：</label>
                </div>
                <div class="item-span">
                    @Html.DropDownListFor(model => model.SexAsInt, ViewBag.Sex as IEnumerable<SelectListItem>, new { @class = "select w-xs" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>生日：</label>
                </div>
                <div class="item-span">
                    <input type="text" value="@(user.Birthday.HasValue?user.Birthday.Value.ToString("yyyy/MM/dd"):"")" id="Birthday" name="Birthday" class="date txt sm" onclick="date()">
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>电话：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.Phone, new { @Value = user.Phone, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>QQ：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.QQ, new { @Value = user.QQ, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>微博：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.Weibo, new { @Value = user.Weibo, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>邮箱：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.Email, new { @Value = user.Email, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>微信：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.WhatApp, new { @Value = user.WhatApp, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>工作：</label>
                </div>
                <div class="item-span">
                    <select id="job" name="job" class="select">
                        @foreach (Job item in ViewBag.Jobs)
                        {
                            <option value="@item.JobName">@item.JobName</option>
                        }
                    </select>
                    @if (user.Job != null)
                    {
                        <script>
                            $("#job").val("@user.Job");
                        </script>
                    }
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>所在城市：</label>
                </div>
                <div class="item-span">
                    <select name="city_list" id="city_list">
                        @foreach (City item in ViewBag.Cities)
                        {
                            <option value="@item.ID">@item.CityName</option>
                        }
                    </select>
                    @Html.HiddenFor(model => model.City, new { @value = @user.City })
                    <input type="hidden" id="city_id" />
                    <script>
                        if ("@user.City" != "") {
                            //设置城市默认值
                            for (var i = 0; i < $("#city_list option").length; i++) {
                                if ($("#city_list").get(0).options[i].text == "@user.City") {
                                    $("#city_list").get(0).options[i].selected = true;
                                    break;
                                }
                            }
                            $("#City").val($("#city_list").children('option:selected').text());
                            $("#city_id").val($("#city_list").children('option:selected').val());
                        }
                    </script>
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>所在区县：</label>
                </div>
                <div class="item-span">
                    <select name="district_list" id="district_list"></select>
                    @Html.HiddenFor(model => model.District, new { @value = @user.District })
                    <input type="hidden" id="district_id" />
                </div>
                <script>
                    //设置区县默认值
                    if ($("#city_id").val() != "") {
                        getDistrict("@user.District", "@user.Town");
                    }
                </script>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>所在乡镇：</label>
                </div>
                <div class="item-span">
                    <select name="town_list" id="town_list"></select>
                    @Html.HiddenFor(model => model.Town, new { @value = @user.Town })
                    <input type="hidden" id="town_id" />
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>地址：</label>
                </div>
                <div class="item-span">
                    @Html.TextBoxFor(model => model.Address, new { @Value = user.Address, @class = "txt sm" })
                </div>
            </div>
            <div class="form-item">
                <div class="item-label">
                    <label>自我描述：</label>
                </div>
                <div class="item-span">
                    <textarea class="resize-none" name="description" id="description">@user.Description</textarea>
                </div>
            </div>
            <div class="form-item">
                <div class="item-span">
                    <input type="submit" value="保存" class="btn">
                    <span class="defInfo">@Html.ValidationSummary(true)</span>
                </div>
            </div>
        }
    </div>
</div>